package com.product.services.impl;

import com.example.product.Product;
import com.product.services.ProductService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

@Service
public class ProductServiceImpl implements ProductService {

    @Override
    public Product getProductById(Long productId) {
        System.out.println("product service: getProductById");
        Product product = new Product();
        product.setProductId(productId);
        product.setProductName("HUAWEI mate-" + productId);
        product.setNum(2);
        product.setPrice(new BigDecimal("99"));

        // 模拟读取超时 其他服务读取时间默认为60秒。
//        try {
//            TimeUnit.SECONDS.sleep(100);
//        } catch (InterruptedException e) {
//          throw new RuntimeException(e);
//        }
        return product;
    }
}
